UrDrive Posted August 2, 2020 Share Posted August 2, 2020 I'm trying to write a Notifications API since the current Rest API returns older notifications first. When writing my API, it returns invalid titles and member groups however it is returning the correct object. Quote Array ( [title] => 7b0f102e25645147e708442f4b2812b9 [url] => IPS\Http\Url\Friendly Object ( [base] => front [seoTemplate] => warn_view [seoTitles] => Array ( [0] => jojojod ) [friendlyUrlComponent] => profile/141353-jojojod/warnings/307 [isInternal] => 1 [isFriendly] => 1 [seoPagination] => [url:protected] => https://maverickcheats.net/community/profile/141353-jojojod/warnings/307/ [data] => Array ( [scheme] => https [host] => maverickcheats.net [port] => [user] => [pass] => [path] => /community/profile/141353-jojojod/warnings/307/ [query] => [fragment] => ) [queryString] => Array ( ) [hiddenQueryString] => Array ( [app] => core [module] => system [controller] => warnings [do] => view [id] => 141353 [w] => 307 ) ) [content] => [author] => IPS\Member Object ( [_data:protected] => Array ( [member_id] => 74283 [member_group_id] => 6 [skin] => 13 [warn_level] => [warn_lastwarn] => 0 [language] => 1 [restrict_post] => 0 [bday_day] => [bday_month] => [bday_year] => [msg_count_new] => 0 [msg_count_total] => 17 [msg_count_reset] => 1596377006 [msg_show_notification] => 0 [last_visit] => 1596370628 [last_activity] => 1596377012 [mod_posts] => 0 [auto_track] => {"content":0,"comments":0,"method":"immediate"} [temp_ban] => 0 [mgroup_others] => 11,9,10 [members_profile_views] => 922 [members_day_posts] => 0,0 [notification_cnt] => 0 [pp_last_visitors] => {"25281":1595956752,"199208":1595964795,"140406":1596069964,"3572":1596207866,"199435":1596220237} [pp_main_photo] => monthly_2020_07/imported-photo-74283.png.c522adf4d210d46469ae15bc96696abe.png [pp_main_width] => [pp_main_height] => [pp_thumb_photo] => monthly_2020_07/imported-photo-74283.thumb.png.2b46a5eed94eac91b0ac8df5a85c5b2a.png [pp_thumb_width] => [pp_thumb_height] => [pp_setting_count_comments] => 1 [pp_reputation_points] => 6 [pp_photo_type] => custom [signature] => <div></div> [pconversation_filters] => [pp_customization] => [timezone] => Europe/London [pp_cover_photo] => monthly_2020_02/83246.jpg.7eb1b724cb0206eea8e3155e21b41ffe.jpg [profilesync] => {"photo":{"handler":3,"ref":"4d9b8bc44038ce8d7c7762fd7bf85ffc","error":null}} [profilesync_lastsync] => 1596330970 [allow_admin_mails] => 1 [members_bitoptions2] => 6161 [create_menu] => {"menu_key":1396789933,"menu":{"member_status":{"link":"https:\/\/maverickcheats.net\/community\/index.php?app=core&module=status&controller=ajaxcreate","title":"status_update","flashMessage":"saved","extraData":{"data-ipsdialog-remotesubmit":true,"data-ipsDialog":true,"data-role":"updateStatus"}},"announcement":{"link":"https:\/\/maverickcheats.net\/community\/modcp\/announcements\/?action=create","title":"add_announcement","extraData":{"data-ipsDialog":true}},"topic":{"link":"https:\/\/maverickcheats.net\/community\/submit\/","extraData":{"data-ipsDialog":true,"data-ipsDialog-size":"narrow"},"title":"select_forum"}}} [members_disable_pm] => 0 [marked_site_read] => 1595333533 [pp_cover_offset] => 140 [acp_skin] => 13 [acp_language] => 1 [member_title] => [member_posts] => 53 [member_last_post] => 1596370774 [member_streams] => [photo_last_update] => 1594846237 [mfa_details] => {"authy":{"id":214208428,"setup":true},"onetouch":{"id":"ef07c3b0-b6f6-0138-852b-0acd7e35ef1b","time":1596377038}} [failed_mfa_attempts] => 0 [permission_array] => [cm_credits] => {"USD":"0.00"} [cm_no_sev] => 0 [cm_return_group] => 3 [idm_block_submissions] => 0 [completed] => 1 [cjdml_exclude] => 0 [cjdml_exclude_note] => [HWID] => 04D8-A824-558B-DC97-FC58-051B-9A0A-3915 [HWID_Resets] => 3 ) [_new:protected] => [changed] => Array ( ) [skipCloneDuplication] => ) [unread] => 1 ) try { $row = \IPS\Notification\Inline::constructFromData( \IPS\Db::i()->select( '*', 'core_notifications', 'member=' . $_GET['member_id'] . ' AND read_time IS NULL' )->first() ); } catch( \UnderflowException $e ) { // error handling here - unable to find transaction } try { if (method_exists( $row, 'getData' ) ) { $ourData = $row->getData(); print_r($ourData); } else { $ourData = array(); } } catch( \LogicException $e ) { $ourData = array(); } Link to comment Share on other sites More sharing options...
Stuart Silvester Posted August 2, 2020 Share Posted August 2, 2020 5 hours ago, UrDrive said: current Rest API returns older notifications first. This was reported as a bug and is fixed in an upcoming release (most likely beta 11) Link to comment Share on other sites More sharing options...
UrDrive Posted August 2, 2020 Author Share Posted August 2, 2020 7 minutes ago, Stuart Silvester said: This was reported as a bug and is fixed in an upcoming release (most likely beta 11) Have any clue what code I have to change to fix it? I could go hunting for it too, it just seems unusual. Link to comment Share on other sites More sharing options...
bfarber Posted August 3, 2020 Share Posted August 3, 2020 applications/core/api/members.php, in the GETitem_notifications() method change the query to sort by updated_time DESC instead of ASC. Stuart Silvester 1 Link to comment Share on other sites More sharing options...
Recommended Posts