DobyTang / LazyLibrarian

This project isn't finished yet. Goal is to create a SickBeard, CouchPotato, Headphones-like application for ebooks. Headphones is used as a base, so there are still a lot of references to it.
732 stars 70 forks source link

No Notifications #1249

Closed gilly65 closed 6 years ago

gilly65 commented 6 years ago

LL version: 1e09a53a0a043dc30a61500d1700228c1d56a457 on a Qnap NAS (linux variant) Interface is bookstrap Goodreads API

I haven't been able to get Pushover or twitter notifications working for quite a while, they both used to work, I can't recall when they stopped, I like pushover notifications as it tells me when something was processed, so I know when I have something new in my library, twitter is fun but non essential, I would like to have them both working, but I would be happy with Pushover.

I think I have my info removed from the file, I checked and my pushover user key and api were still in it, not sure about twitter though... debug.zip

Basically, twitter won't authenticate, I get a 401 error, Pushover says it worked but it doesn't.

philborman commented 6 years ago

Ah - the pushover api and user key might get left in the test button debug message!
We strip them from all the other log lines, missed that one. Will fix it in the next release.

Unfortunately I don't use pushover or twitter myself, so am unable to test. PushBullet/email/custom are all working, they are the ones I use regularly, so there isn't a general notification issue, it's specific to those notifiers somewhere.

From the log you sent it looks like communication with pushover is ok, we get a valid response from the test button. Might need to see a log section from a real notification to see why it might fail. We're obviously talking to pushover ok and authentification is fine. Twitter is more complicated as even the test button fails. 401 is an authentication error, I will see if there is anything obvious changed in that section of code. Might need to send you a version with more debugging in it. Any way of narrowing down when it stopped working, would help with looking through older versions of code to see what's changed.

philborman commented 6 years ago

Looking at the twitter test button results, twitter sends us "Invalid request token" which looks like the twitter username or twitter password are incorrect. Can you check them?

philborman commented 6 years ago

Looking through the twitter notifier code there are a few oddities. I think you might need to go through the twitter authorisation process again, button1 then button2 as it seems they set the "username" and "password" for you, but they are not user/pass at all they are oauth tokens. There is also a "twitter key" field that doesn't seem to be either set or used anywhere? At the moment your log shows the oauth tokens are empty so that's not going to work.

Unfortunately I'm getting nowhere with pushover. I had a trial account back in 2015 which was only for 7 days, got pushover working then, but haven't got free access any more. Could maybe send you some extra heavy debugging code to try?

gilly65 commented 6 years ago

I revoked access to twitter, then tried again, this is the bit of log file it created:

2018-03-06 06:38:20 INFO Sending tweet: : This is a test notification from LazyLibrarian / 2018-03-06 06:38:20
2018-03-06 06:38:17 INFO Config file [/share/CACHEDEV1_DATA/.qpkg/LazyLibrarian/config/config.ini] has been updated
2018-03-06 06:38:15 INFO result: True
2018-03-06 06:38:15 INFO Access Token secret: removed
2018-03-06 06:38:15 INFO Your Twitter Access Token key: removed
2018-03-06 06:38:15 INFO resp[status] = 200
2018-03-06 06:38:15 INFO access_token: {'oauth_token_secret': 'removed', 'user_id': 'removed', 'x_auth_expires': '0', 'oauth_token': 'removed', 'screen_name': 'my_screen_name'}
2018-03-06 06:38:15 INFO resp, content: {'content-length': '184', 'x-tsa-request-body-time': '0', 'x-xss-protection': '1; mode=block; report=https://twitter.com/i/xss_report', 'x-content-type-options': 'nosniff', 'x-connection-hash': 'ddd6f9f67ac5591b55333e83b220d0b3', 'x-twitter-response-tags': 'BouncerCompliant', 'x-ua-compatible': 'IE=edge,chrome=1', 'cache-control': 'no-cache, no-store, must-revalidate, pre-check=0, post-check=0', 'status': '200', 'set-cookie': 'personalization_id="v1_IOWmVjWSR6cD5evhKFG8Vw=="; Expires=Thu, 05 Mar 2020 10:38:15 UTC; Path=/; Domain=.twitter.com, guest_id=v1%3A152033269496047610; Expires=Thu, 05 Mar 2020 10:38:15 UTC; Path=/; Domain=.twitter.com', 'expires': 'Tue, 31 Mar 1981 05:00:00 GMT', 'last-modified': 'Tue, 06 Mar 2018 10:38:15 GMT', '-content-encoding': 'gzip', 'pragma': 'no-cache', 'date': 'Tue, 06 Mar 2018 10:38:15 GMT', 'x-response-time': '280', 'content-security-policy': "default-src 'none'; connect-src 'self'; font-src https://abs.twimg.com https://abs-0.twimg.com data:; frame-src 'self' twitter:; img-src https://abs.twimg.com https://*.twimg.com https://pbs.twimg.com data:; media-src 'none'; object-src 'none'; script-src https://abs.twimg.com https://abs-0.twimg.com https://twitter.com https://mobile.twitter.com; style-src https://abs.twimg.com https://abs-0.twimg.com; report-uri https://twitter.com/i/csp_report?a=NVQWGYLXFVWG6Z3JNY%3D%3D%3D%3D%3D%3D&ro=false;", 'x-transaction': '0022d4210097f236', 'ml': 'S', 'strict-transport-security': 'max-age=631138519', 'server': 'tsa_a', 'x-frame-options': 'SAMEORIGIN', 'content-type': 'text/html;charset=utf-8'},oauth_token=removed&oauth_token_secret=removed&user_id=2324205829&screen_name=my_screen_name&x_auth_expires=0
2018-03-06 06:38:14 INFO oauth_client:
2018-03-06 06:38:14 INFO oauth_consumer: oauth_consumer_key=removed&oauth_consumer_secret=removed
2018-03-06 06:38:14 INFO Generating and signing request for an access token using key 0539565
2018-03-06 06:38:00 INFO Requesting temp token from Twitter

It says it worked but it didn't post. Pushover still says it worked, but it didn't, I have verified all keys and u/n and p/w and they are all correct.

Pushover is free, you only have to pay if you need more than 7500 notifications a month, per app, on a per user basis. I have 14 or 15 apps setup and have never got a bill or even an email saying I need to upgrade, it works well for me.

gilly65 commented 6 years ago

It seems to be communicating with pushover, I noticed it was saying it was successful in sending notifications to 2 devices, so I removed one of them on the pushover site, now it's saying it sent to the device I am using, but it doesn't get to it.

philborman commented 6 years ago

Pushover: The test pushover button should return a list of valid devices which it gets from pushover. If we get that far we must be authenticated or it wouldn't give us the device ids. Not sure if you have to give a device, or if blank means "send to all" which is how pushbullet works. Might be worth trying without a device? My pushover account says "Disabled, Trial Expired" next to each device. Maybe it's device specific rather than account specific, I might try adding another device.

Twitter: Can you check your twitter config file and see if there is anything stored for TWITTER_USERNAME and TWITTER_PASSWORD, they should get generated by the authorise buttons and saved to the config file for future tweets. The log looks like it generated them ok, and it thinks it sent the tweet as far as we can tell. When you hit the "test twitter" button did you get a popup saying "Tweet successful, check your twitter to make sure it worked" or did you get "Error sending tweet", or did you get nothing at all?

philborman commented 6 years ago

ok, just signed up a new device to pushover (7 day limit again) and it seems to be working here. Just ran the test and got my new device id back (only that one, not the expired ones) just snatched a book and got the pushover notification telling me.

philborman commented 6 years ago

Still not sure what's going on with twitter, but I think pushover is probably working, you just don't realise it. Seems the current code for pushover and pushbullet get the device list back (which requires auth) so that's enough of a test to know it's working. No actual message gets sent. Not sure if twitter is the same, no way of testing it. I have just added some code to pushbullet and pushover so they also send a message if the auth looks ok. Will push a new version probably tomorrow.

gilly65 commented 6 years ago

In config.ini there is nothing saved for twitter u/n or p/w, I wondered if I should fill that in or leave it. Pushover indeed seems to be working, yet I'm still not getting any notifications on my device, I will remove it and reinstall it and see what happens I guess.

philborman commented 6 years ago

Looking through the code it seems the way it's supposed to work is... PART 1 Request authorization button requests a temporary token from twitter and saves the results in the badly named twitter_username and twitter_password fields. It then uses this token to open a webpage on the twitter site where you fill in your real twitter details and authorize the token. This generates a twitter_key which is stored in the lazylibrarian config interface. You should see log messages saying "Requesting temp token from Twitter" "Twitter oauth_token = %s oauth_secret = %s" PART 2 Now the temporary token is authorized and we have a key, the Verify Key button is used to send the temporary token and the key back to twitter to get a new permanent token, again stored in the twitter_username and twitter_password fields. You should see log messages saying "Generating and signing request for an access token using key %s" "access_token: %s" "Your Twitter Access Token key: %s" "Access Token secret: %s" PART 3 At this point the Test Twitter button should work. It should collect the permanent token from part 2 and send a tweet.

At some point in this process the system fails. Can you confirm if this process is what really happens (or seems to happen) so I'm sure I've understood it correctly. If I have understood the process correctly and it's still not working and nothing in config.ini I might have to send you a version of tweet.py with more debugging in it to try and crack this.

gilly65 commented 6 years ago

Twitter: press "Request Authorization" button twitter opens in a new tab, to the proper request app authorization page, you click on authorize and it gives you the code, put the code in the LL settings box "Twitter Authorization Key" Click on "Verify Key" (and then save) and that should be it, it seems to work but it doesn't post to twitter, I'm not overly concerned about twitter, it's on a secondary account and twitter notifications are a novelty.

Pushover: your latest update now has me receiving notifications, not sure what you did, but thank you very much, I am happy with Pushover working!

philborman commented 6 years ago

ok, I will close this for now.

philborman commented 6 years ago

I think the twitter problem is that you should not press ENTER or SAVE after typing in the twitter key, if you do so the key is lost and the box clears. Just go straight to [Verify Key] while the key is visible on screen, and only save after pressing [Test Twitter] is successful.

gilly65 commented 6 years ago

There is a hash in the config.ini for twitter u/n & p/w now, the log says it works, but it still isn't posting, even after the new update and instructions (I had tried that before to no avail too), there is no popup either like there is for pushover, should there be? Again, Twitter is not a big deal, I am happy that pushover works, that is the one I use regularly.

Thanks

philborman commented 6 years ago

There should be a popup, but it's broken. Just signed up for a twitter account (don't do social media so will delete it again tomorrow). Fix shouldn't be too hard now I can test it.