Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL is bad in notifications part of API #18

Open
Leo32345 opened this issue Jan 17, 2022 · 7 comments
Open

URL is bad in notifications part of API #18

Leo32345 opened this issue Jan 17, 2022 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed verified verified as valid by a maintainer

Comments

@Leo32345
Copy link

There is an "undefinedundefined" part in the url that does not work. Is there any way I can fix this?
image

@qwazwsx
Copy link
Collaborator

qwazwsx commented Jan 18, 2022

hm, sorry that you are having problems with the library. thanks for submitting an issue :)

the notification URL is built like so (index.js:556)

this.district.district_baseurl + notification.linkUrl + notification.linkContext,

based on your screenshot it looks like the .linkUrl and .linkContext properties are missing from the notification object returned by Infinite Campus. It's likely that the Infinite Campus server version your school is using has a different way of storing this info, probably .urlLink instead of .linkUrl or something like that. I.C. likes to change the property names around which really makes my life difficult.

Anyways, on to fixing this.
If you send me the debug output from here: https://replit.com/@qwazwsx/Infinite-Campus-Debug, I'll add support for your version of Infinite Campus and update the library ASAP. Feel free to redact any info you feel is sensitive. Alternatively, you can make these changes to the library to get the same debug output locally.

Send me the debug output and I'll get back to you ASAP.

@qwazwsx qwazwsx added bug Something isn't working question Further information is requested labels Jan 18, 2022
@Leo32345
Copy link
Author

Leo32345 commented Jan 18, 2022

Thanks for the fast response!
Also, I just was looking at my school's infinite campus site, and it says: Version: Campus.2148.8.
Anyway the (beginning part of) the output is below:

User {
  _events: [Object: null prototype] { error: [Function], ready: [Function] },
  _eventsCount: 2,
  _maxListeners: undefined,
  meta: { version: '2.0.0', github: 'qwazwsx/infinite-campus' },
  authenticated: false,
  cookies: RequestJar {
    _jar: CookieJar { enableLooseMode: true, store: { idx: {} } }
  },
  hasErrorListener: false,
  [Symbol(kCapture)]: false
}
Hint: hit control+c anytime to enter REPL.
FETCHING NOTIFICATIONS...

 [GET NOTIFICATIONS][#0] {
  notificationID: '660642045',
  userID: '231660',
  creationTimestamp: '01/18/2022 09:12:55 -0700',
  notificationTypeID: '4',
  read: 'false',
  notificationText: 'Leo received a score of 10 out of 10 on *** in ***',
  notificationTypeText: 'Assignment Score Event',
  displayedDate: 'Today, 9:12 AM',
  finalText: 'Leo received a score of 10 out of 10 on *** in ***',
  finalUrl: ''
}
…

Then it ends with stuff that looks like this:

[
 {
   id: '660642045',
   text: 'Leo received a score of 10 out of 10 on *** in ***,
   timestamp: 1642522375,
   timestampText: 'Today, 9:12 AM',
   type: '4',
   link: 'https://campus.************.com/campus/undefinedundefined',
   read: false,
   toggleRead: [Function: toggleRead]
 },
 … ]

If you need more information, feel free to let me know.

@qwazwsx
Copy link
Collaborator

qwazwsx commented Jan 19, 2022

Thanks for posting your debug output!

From what I can see from the important bit here

...
 [GET NOTIFICATIONS][#0] {
  notificationID: '660642045',
  userID: '231660',
  creationTimestamp: '01/18/2022 09:12:55 -0700',
  notificationTypeID: '4',
  read: 'false',
  notificationText: 'Leo received a score of 10 out of 10 on *** in ***',
  notificationTypeText: 'Assignment Score Event',
  displayedDate: 'Today, 9:12 AM',
  finalText: 'Leo received a score of 10 out of 10 on *** in ***',
  finalUrl: ''
}
...

As suspected, the notification objects returned from I.C. do not contain the .linkUrl and .linkContext properties that this library uses. I suspect that your version of I.C. uses the notification ID to construct a URL rather than specifying the URL directly. It'd look a little something like this

'https://my-district.infinitecampus.org/campus/API/whatever/blah/blah/notification?id=660642045

Unfortunately, I no longer have access to Infinite Campus, which makes maintaining an Infinite Campus library very difficult. Is there any way you can send me an example of the notification link from the Infinite Campus website? Maybe by right-clicking on the notification and copying the link? If not I'll have a friend get me the link format in the morning and I should be able to investigate this more. Sorry for the delay.

@Leo32345
Copy link
Author

The URL for that notification when you click on it is:

https://campus.***************.com/campus/nav-wrapper/student/portal/student/classroom/2023019/curriculum/resource/7521225/view?studentID=466894&notification=true&userType=student

It looks like that the IDs in the URL are different from the one in the API sadly.

@qwazwsx
Copy link
Collaborator

qwazwsx commented Jan 19, 2022

hmm, okay that's unfortunate.

let's try this new debug version
https://replit.com/@qwazwsx/Infinite-Campus-Notification-Debug-2

and then could you send me the output labeled "[RAW NOTIFICATION PRISM OUTPUT]". This should be the raw output from the getNotification API endpoint. Feel free to anonymize anything or send the output to my email Alfa Zulu India Mike Bravo India November @gmail.com

There's a chance they restructured the whole layout of the Notifications API. This will just let me get a closer look at how the data is structured.

@Leo32345
Copy link
Author

Okay, so the output looks like this:

{"status":"OK","data":{"NotificationList":{"Notification":[{"notificationID":"660642045","userID":"231660","creationTimestamp":"01/18/2022 09:12:55 -0700","notificationTypeID":"4","read":"true","notificationText":"Leo received a score of 10 out of 10 on **** in ********","notificationTypeText":"Assignment Score Event","displayedDate":"Today, 9:12 AM","finalText":"Leo received a score of 10 out of 10 on **** in ********","finalUrl":""},{"notificationID":"660642013","userID":"231660","creationTimestamp":"01/18/2022 09:12:55 -0700","notificationTypeID":"3","read":"true","notificationText":"Leo has an updated grade of  A (100.00%) in ****: QUARTER GRADE","notificationTypeText":"Grade Event","displayedDate":"Today, 9:12 AM","finalText":"Leo has an updated grade of  A (100.00%) in ******* QUARTER GRADE","finalUrl":""}, 

Anyways, thanks for the fast response. Unfortunately, I will be offline soon for about almost a day, so I may not reply for a while.

@qwazwsx
Copy link
Collaborator

qwazwsx commented Jan 20, 2022

I had a friend with access to I.C. check it out and they are having the same issue.

I'll have to look into this more. If the URL's aren't coming from the getNotifications endpoint I'm not sure where they are coming from

I know @Lathryx expressed some interest in helping me maintain this library. Perhaps they could look into this?

Heres a recap on what we know so far

  • On older versions of I.C. notifications are to built using the .linkUrl and .linkContext properties of the notification object
    (index.js:556)
this.district.district_baseurl + notification.linkUrl + notification.linkContext,
  • Now these two properties are missing and there is a .finalUrl property which always returns an empty string
{
  notificationID: '660642045',
  userID: '231660',
  creationTimestamp: '01/18/2022 09:12:55 -0700',
  notificationTypeID: '4',
  read: 'false',
  notificationText: 'Leo received a score of 10 out of 10 on *** in ***',
  notificationTypeText: 'Assignment Score Event',
  displayedDate: 'Today, 9:12 AM',
  finalText: 'Leo received a score of 10 out of 10 on *** in ***',
  finalUrl: '',
  // the below properties used to exist but now they don't
  linkUrl: undefined
  linkContext: undefined
}

It's important to note that we should always maintain backward maintainability so any changes must support both the old and new ways of building notification URL's.

Any and all help is appreciated in investigating this.

@qwazwsx qwazwsx added the help wanted Extra attention is needed label Jul 8, 2022
@qwazwsx qwazwsx added the verified verified as valid by a maintainer label Sep 19, 2022
@qwazwsx qwazwsx removed the question Further information is requested label Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed verified verified as valid by a maintainer
Development

No branches or pull requests

2 participants