Git Product home page Git Product logo

redd's People

Contributors

alfredoramos avatar avinashbot avatar christopher-dg avatar fustrate avatar scragz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

redd's Issues

Request forbidden by administrative rules.

Hi, I add this piece of code to get the error information:

begin
  puts "starting main thread....."
  stream_all!(bot, subreddit_list)
rescue Exception => e
  puts "big error we need to fix: #{e}"
end

After several hours without any activity, I got "Request forbidden by administrative rules.". How can I fix this?

Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (execution expired), retrying...
Redd got a Redd::ServerError error (<!doctype html>
<html>
<title>Ow! -- reddit.com</title>
<style>
body{text-align:c...), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (execution expired), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
Redd got a HTTP::TimeoutError error (Read timed out after 5 seconds), retrying...
big error we need to fix: <html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.

Next page

hey, I saw your post on the repos reddit page. I tired the example code you commented but I got some weird error that the second page variable is not found. I checked the repo to see if you created a function to get more pages, I did not see one. Its pretty late right now and im tired so I prob missed it or its a dumb fix.

My code is:

    num = rand(1...100)
    r_all = reddit.subreddit("snapfuck")
    post = r_all.top(time: :all, after: second_page.after)
    post_url = post.url
    check_url = post_url.split(".").last
    puts check_url, post_url

My code before I attempted to edit it was, there was a big list of certain subreddits and it would pick one by random and then scrape a random image from that page.

subredit =  [ 'sample7', 'sample6', 'sample5', 'sample4', 'sample3', 'sample2', 'sample1'].sample
num = rand(1...100)
r_all = reddit.subreddit(subreddits)
post = r_all.hot[num]
post = r_all.top(time: :all, after: second_page.after)
post_url = post.url
check_url = post_url.split(".").last
puts check_url, post_url

its prob an easy fix, but i cant figure it out. prob been working on it to long and got tunnel vision.

Using registered web app credentials inside an ActiveJob

  • Rails 5.0.2
  • Redd 0.8.8

Hello, once again! I'm at yet another stumbling point right now. My code is based on your comment (#54 (comment)) on another issue I posted. But I felt it would be best to open a new issue, since I have since removed Omniauth-reddit from the mix.

Basically, my code for starting a session through the app works. But what I need help with is using the session from request.env['redd.session'] inside an ActiveJob. I did some research, and only certain objects can be passed to an ActiveJob -- my error and findings.

I got this working a couple weeks ago, but forgot to either document it or commit to git.

Here's my initializer for Redd:

# config/initializers/redd.rb

require "redd/middleware"

Rails.application.config.middleware.use Redd::Middleware,
  :user_agent   => "Redd:junk-drawer (by /u/1bree)",
  :client_id    => ENV["REDDIT_KEY"],
  :secret       => ENV["REDDIT_SECRET"],
  :redirect_uri => ENV["REDIRECT_URI"],
  :scope        => %w(identity save history),
  :via          => "/login"

And here's what I have in my job right now.

# app/jobs/collect_saved_things_job.rb

class CollectSavedThingsJob < ApplicationJob
  queue_as :default

  # user -> User record
  # access_token -> session["redd_session"]["access_token"]
  def perform(user, access_token)
    strategy = Redd::AuthStrategies::Web.new(
      :user_agent   => "Ruby:Redd:junk-drawer (by /u/1bree)",
      :client_id    => ENV["REDDIT_KEY"],
      :secret       => ENV["REDDIT_SECRET"],
      :redirect_uri => ENV["REDIRECT_URI"]
    )

    client = Redd::APIClient.new(strategy)

    client.access = Redd::Models::Access.new(
      strategy,
      :access_token => access_token
    )

    session = Redd::Models::Session.new(client)

    saved_things = []

    after = nil

    loop do
      # Get all posts after the posts in the `after` variable
      # ERROR HERE
      results = session.me.saved(:after => after, :limit => 10)

      # Store the fetched results
      saved_things.concat(results)

      # Keep track of what post to get the saved posts after
      after = results.after

      break if after.nil?
    end

    raise  # for testing
  end
end

On the line where results is defined, I get the following error:

Redd::InvalidAccess in SavedThingsController#collect
{"message": "Unauthorized", "error": 401}

Which on the surface makes sense -- the user is not logging into the app through the Reddit auth page. I am instead re-using the access token through some part of the session hash... but that just feels like a weird doesn't-work-around. Like I said, I am using access_token like I would have if I continued to use omniauth-reddit, but instead grabbed it from the session['reddit_session'] hash and all.

NoMethodError: undefined method `fullname' for [:kind, nil]:Array

We have been getting the following error a few times in the last weeks. We're using 0.7.10.

I have no idea what the cause behind this is. Perhaps it's just the Reddit API returning an unexpected response.

NoMethodError: undefined method `fullname' for [:kind, nil]:Array
  redd/clients/base/stream.rb:65:in `block (2 levels) in stream'
    yield thing if bset.enqueue?(thing.fullname)
  redd/clients/base/stream.rb:64:in `reverse_each'
    listing.reverse_each do |thing|
  redd/clients/base/stream.rb:64:in `block in stream'
    listing.reverse_each do |thing|
  redd/clients/base/stream.rb:58:in `loop'
    loop do
  redd/clients/base/stream.rb:58:in `stream'
    loop do
...

Streaming and InvalidOAuth2Credentials

Same issue #19 . I think the prob is still unsolved.

Here's my observation (In code comment)

https://github.com/avinashbot/redd/blob/master/lib/redd/access.rb#L46

# Should it be, now + N > expiration ??
def expired?
  Time.now > (@expires_at + 60)
end

https://github.com/avinashbot/redd/blob/master/lib/redd/clients/base.rb#L155

# refresh_token or re-authorize won't work becuz the underlying connection is never reset
def connection
  @connection ||= Faraday.new(
     @api_endpoint,
     headers: default_headers,
     builder: middleware
  )
end

Any way to change search "sorted by" to new?

I am a novice developer using REDD to make a simple rails app for tracking of deals and flash sales as listed on a subreddt. Users create a custom list of keywords of the brands they want to appear on a custom deals page. However, when I use the search syntax set up in the examples on github, the results are the same as when someone searches the subreddit for a string, as in the results from a "sorted by: relevance" filter. I'm wondering if there is any way to change the "sorted by" option when searching to "sorted by; new".
The code in my controller is as follows:

@keywords = ["J.Crew"]
@deals = []
@keywords.each do |keyword|
  sales = session.subreddit('frugalmalefashion').search(keyword)
  sales = sales.sort_by { |sale| sale.created }.reverse
  sales.each do |sale|
    if sale.link_flair_text == "[Deal/Sale]"
      @deals << sale
    end
  end
end

is there any way to change the sorted by property when I call .search(keyword) on a session?

'before' options returns too many things

When requesting for example the newest comments in a subreddit, adding the 'before' option shows all comments. The expected result would be all comments newer than the comment specified (fullname of the comment passed via 'before:').

Example:

comments = session.subreddit('scotch').comments(before: 't1_dt288wj') # substitute with more recent fullname
enum = comments.stream

100.times do
  puts enum.next.name
end
# observe that at some point we get the comment with the given fullname and
# afterwards all the older comments ordered by descending time.
# likewise for enum = comments.each

Version: 0.9.0.pre.3

Analysis

My guess is that it comes from #fetch_prev_listing in PaginatedListing. If the returned listing is empty, it will set @before to nil. Is this intended behaviour? I would expect one of three things:

  1. Raise a StopIteration
  2. Return nil
  3. Block and poll frequently until a new listing item (comment in this case) is available.

Raising StopIteration would have my preference, but that might make it harder to restart the listing. Blocking would be difficult if you want to combine different streams. For example, if you would want to iterate over both comments and submissions at the same time. (addition:) Instead of blocking, we could also use the concurrent-ruby gem to do the polling on a separate thread. Anytime when new data is available we can send a message to the obserber/block.

If this is intended behaviour, how would I approach this in an application where I only want to receive newer items?

NoMethodError: undefined method `reverse_each' for nil:NilClass

Somehow listing = send(meth, *args, **params) ended up being nil for me at redd/clients/base/stream.rb:64 (exception caught with Sentry):

Stacktrace (most recent call first):

  redd/clients/base/stream.rb:64:in `block in stream'
    listing.reverse_each do |thing|
  redd/clients/base/stream.rb:58:in `loop'
    loop do
  redd/clients/base/stream.rb:58:in `stream'
    loop do
  /app/lib/reddit.rb:14:in `stream_urls'
    reddit.stream "get_#{sort}", "all" do |thing|
  /app/lib/reddit_provider.rb:22:in `run'
    reddit.stream_urls(sort) do |url|
  reddit-provider.rb:6:in `block in <main>'
    RedditProvider.new.run
  raven/base.rb:96:in `capture'
    yield
  reddit-provider.rb:5:in `<main>'
    Raven.capture do

My code using #stream (simplified):

reddit = Redd.it(:userless, id, secret, user_agent: USER_AGENT)
reddit.authorize!

reddit.stream "get_new", "all" do |thing|
  # do stuff
end

Any idea of what might gone wrong?

Looks like redd/clients/base/utilities.rb:48 kicked in

return nil unless body.is_a?(Hash)

I wonder why body wasn't a Hash.

undefined method `it' for Redd:Module

Hi,

I have an issue when using the gem from a Rails app. All works fine from a Ruby console app but in Rails, when adding the following lines in my controller action:

r = Redd.it(:userless, "CLIENT_ID", "SECRET")
r.authorize!

I get the following error: undefined method 'it' for Redd:Module

What am I doing wrong? Been banging my head for the past hour. Thanks!

`it': couldn't guess app type (RuntimeError) in redd-0.9.0.pre.3

Using the pre-3 gem, and the basic bot example from the readme (with my own credentials), I get the error:
/usr/local/lib/ruby/gems/2.5.0/gems/redd-0.9.0.pre.3/lib/redd.rb:67:in 'it': couldn't guess app type (RuntimeError)

require 'redd'

session = Redd.it(
  user_agent: 'Redd:RandomBot:v1.0.0 (by /u/Mustermind)',
  client_id:  'PQgS0UaX9l70oQ',
  secret:     'PsF_kVZrW8nSVCG5kNsIgl-AaXE',
  username:   'RandomBot',
  password:   'hunter2'
)

MacOS High Sierra, with ruby 2.5 from homebrew.
Could another updated gem have broken it or?

Streaming and InvalidOAuth2Credentials

I didn't want to continue off topic in #18, so therefore a new issue. Hope you are okay with me continuing asking, this might not be an particular issue with the library, just me having a rough time using it.

Anyways, you wrote in #18

The 401 error, on the other hand, I can diagnose. The error pops up because the session expires every hour. A simple line of code can fix it. I would put that line of code directly in the stream method, but I was worried about repeat requests and possibly IP bans if the Access object wasn't properly constructed.

reddit.refresh_access! if reddit.access.expired?
# ... more code ...

So I tried that... doing it like this

reddit = Redd.it(:userless, id, secret, user_agent: USER_AGENT)
reddit.authorize!

reddit.stream "get_new", "all" do |thing|
  reddit.refresh_access! if reddit.access.expired?
  yield thing
end

but I keep getting 401. Was this how you thought it should be done or did you have something else in mind?

Module: Redd::Clients::Base::Read#from_fullname uses a deprecated method, returns 403 Forbidden

Hi, I'm not sure whether I've just been programming for too long or if this is really an error but here goes!

I was trying to get a specific Thing but Redd kept returning an uninitialized JSONError. As it turns out the method used by #fullname, /api/info, returns a 403.

w.request_object(:get, "/api/info", id: "t3_6nw57")
=> NameError: uninitialized constant Redd::Response::ParseJson::JSONError

This can be seen on the Reddit API console as well. As far as I can tell Reddit left this method available while not actually supporting it anymore. (? idk.)

=> HTTP/1.1 403 Forbidden
     <html><body><h1>403 Forbidden</h1>
     Request forbidden by administrative rules.
     </body></html>

by_id seems to be the currently supported way to get an object by it's `id´:

w.request_object(:get, "/by_id/t3_6nw57.json", {}) 
=> Redd::Objects::Submission 

I'm using the Userless client, which I'm pretty sure should support every method in Reddit's Read oauth scope.

If you want I'll issue a pull request sometime during the next days.
Also, I really enjoyed browsing your source code. Not a Ruby expert but it seems very well put together!

Rate limiting is guessing

If Reddit changes their API to allow 50 requests per minute your sleep will be too slow.

Instead of having a class that tracks time (or even allowing the user to provide a time tracking object) I suggest simply reading the HTTP headers they provide and determining the availability to request then. See the wiki details:

X-Ratelimit-Used: Approximate number of requests used in this period
X-Ratelimit-Remaining: Approximate number of requests left to use
X-Ratelimit-Reset: Approximate number of seconds to end of period

OAuth scope "mysubreddits" doesn't appear to be working properly

get requests to relevant endpoints return 403s

Edit:

I tried this on /subreddits/mine/moderator

if session[:access]
  session_access = Redd::Access.from_json(session[:access])
  $redd_web.with(session_access) do |_client|
    _client.refresh_access! if session_access.expired?
    _client.get '/subreddits/mine/moderator'
  end
end

Edit 2:

Reddit is recognizing the OAuth scope during the initial OAuth handshake, and the scope seems to show up in Redd locally after authentication, it's only when I actually try to hit an endpoint covered by the mysubreddits scope that I see any issues. Other scopes so far work without issue.

Proposal: Abstract over Listing Pages with a `PaginatedListing`

For reasons to do with simplicity, listings are one of the few types are aren't lazily created. The idea is to have listings return a PaginatedListing that abstracts over listing pages and thus only present an Enumerable to the user.

This is a breaking change because listing methods would no longer return typical Listings, but with sensible coding (like setting the default limit to 100 so no more than 100 are fetched if the key is omitted), nothing obvious should change.

I'll just mark this as a proposal because I'm a little busy at the moment and while I tell myself it's more of a reminder for me, I just secretly hope someone submits a PR 😉.


EDIT: This could also be helpful for flairs, but those listings use prev and next keys.

Documentation/Example Request

Hi everyone,

I don't believe the GitHub Issues is the best place for this request, but I'm not sure where else to post to get the exposure. My problem is that I'm a novice to Ruby and a complete newbie to using the Redd gem and as a result I'm struggling to get going with the codebase. The README's code example is ok, but extremely basic. However, there aren't any other code examples covering basic tasks like getting a list of a Subreddit's posts, viewing a user's profile, etc. Does anyone have sample code they can provide to help get me moving?

Thanks,

Brendan

Trouble reading documentation

I am not sure if it's just me, my browser, or the documentation, but I am having trouble finding some features or methods to achieve these features.

I am wanting to firstly iterate all topics from a sub reddit with a specific string in its title and gather this specific information consisting of title, post text, attached URLS to post, and then search the comments of that post for a specific string. This would require some kind of search function or the like.

Secondly I am wanting to stream all new topics that have a specific string in its title and gather the previously mentioned information.

Basically I want to catalogue and store specific tagged posts from a sub reddit in a searchable database that I can later use in other applications.

Thanks!

PaginatedListing returns empty Submission objects

Hi,

I've been using the new 0.9.0.pre.3 prerelease and I've noticed that when checking if a list is empty, PaginatedListing returns a list of empty Submission objects.

Example:

links = session.subreddit(...).new(
  before: 't3_xxxxx'
)

With redd v0.8.8

p links.to_a
# => []

With redd v0.9.0.pre.3

p links.to_a
# => [#<Redd::Models::Submission (unloaded): []>, #<Redd::Models::Submission (unloaded): []>, ...]

I'm trying to check if there's new submissions, so with the previous test links.to_a should be empty ([]) because there's no new links after that fullname, however with the 0.9.0.pre.3 prerelease all the submissions are listed, but they all are empty Submission objects.

With this new behavior links.to_a.empty? never returns true even if there's no new submissions.

refresh_token lost during refresh

Me again 😄 So when I run @client.refresh, @client.access is reset using the response from

@access = @auth.refresh(@access)

but that doesn't include the refresh token or any other information that's not in the response. I personally use the refresh token to know which row in the database to update when I refresh the token.

I made one small change in my local copy to get around this, but I'm not sure if it's the right thing to do for anything other than refreshing the web auth strategy:

module Redd
  module AuthStrategies
    # The API client for authentication to reddit.
    class AuthStrategy < Client
      private

      def request_access(grant_type, options = {})
        response = post('/api/v1/access_token', { grant_type: grant_type }.merge(options))
        Models::Access.new(self, options.merge(response.body))
      end
    end
  end
end

Failed to authenticate

I'm trying to test out like this:

r = Redd.it(:script, client_id, cient_secret, username, password)
r.authorize!

The call above will make a request to /api/v1/access_token with a request header like

{
    "User-Agent": "Redd/Ruby, v0.7.3",
    "Authorization": "Basic …"
}

and a request body like

{
    grant_type: "password",
    username: "…",
    password: "…"
}

and I get this:

redd/lib/redd/response/raise_error.rb:12:in `on_complete': {:error=>"invalid_grant"} (Redd::Error::ExpiredCode)

I'm stuck and I'd appreciate if you could suggest me what I'm doing wrong. Thx!

Retrieving Comments using name

If i have the name of a listing such as t3_85ahch in askreddit, how can i retrieve all comments for that listing?

Tried something like this, but not working.

session.subreddit('awardtravel').submission(from_id: "t3_85ahch").comments
NoMethodError: undefined method `from_id' for #<Redd::Models::Listing:0x0>

getaddrinfo: Name or service not known (Faraday::ConnectionFailed)

I looked around a bit and couldn't figure this one out. Basically when I'm streaming comments, every 5 or 10 minutes it crashes and I get this error:

/usr/local/lib/ruby/2.2.0/net/http.rb:879:in `initialize': getaddrinfo: Name or service not known (Faraday::ConnectionFailed)

code:

r = Redd.it(:script,
    ENV['REDDIT_CLIENT_ID'],
    ENV['REDDIT_SECRET'],
    ENV['REDDIT_USERNAME'],
    ENV['REDDIT_PASSWORD'],
    user_agent: 'test')

r.authorize!

r.stream :get_comments, "all" do |comment|
    r.authorize! if r.access.expired?
    if topics.any? { |topic| comment.body.downcase.include?(" #{topic} ") }
      puts comment.body
    end
  end
end
redd (0.7.8)
      faraday (~> 0.9.1)
      fastimage (~> 1.6.6)
      hashie (~> 3.4.0)
      multi_json (~> 1.10.1)

Am I doing something wrong?

Re-authorizing a userless Client returns a 401 error

Steps to reproduce:

  1. reddit = Redd.it(:userless, 'CLIENT_ID', 'CLIENT_SECRET')
  2. reddit.authorize!
  3. reddit.search('cats') -> Query / use of API successful.
  4. Wait for access token to expire (1 hour)
  5. reddit.authorize! -> New access token received
  6. reddit.access.expired? -> Returns false
  7. reddit.search('cats') -> 401 error received (Invalid OAuth2 Credentials), expected successful API use.

I have a work-around in place where I wrap steps 1 and 2 in a function and call it if reddit.access.expired?, but this seems like unnecessary behavior, especially considering that subsequent uses of reddit.authorize! do successfully get a new, valid access token. I'm not sure why I have to recreate the Client object through Redd.it.

How to create a web session?

Right now for my app, I am using omniauth-reddit to authenticate users. I see that to start a session, I can create a web client with Redd. Following the instructions in the docs, however, did not work. (I searched based on the #it method used in the demo on the README)

http://www.rubydoc.info/github/avinashbot/redd/master/Redd.it

web = Redd::AuthStrategies::Web.new(**arguments)
client = Redd::APIClient.new(web); client.authenticate

I get an error that authenticate requires a parameter for code. I tried reading the Reddit API and couldn't find what this code is, or where I would get it from. Ideally, this is what I want my workflow to be:

  1. Authenticate via Reddit, and redirect to my app's homepage
  2. Queue an ActiveJob that syncs the user's saved posts to my app (related issue) -- use Redd to grab this data
  3. Show the user's saved things on the home page

I don't think I would use Redd to authenticate the user to my app instead, right? Or would I? For right now, I only need to start a session per user once a day, or if they click a button to grab new info.

Thank you.

comment.replies not working consistently

This will probably be really vague and not helpful to debug, bug earlier I was able to get the Listing of comment replies from a Comment with the_comment.replies but now it returns an empty listing. The comments I'm applying it to very definitely has replies, so I'm not sure what to do. The replies method also isn't documented unfortunately.

No support for POST api/submit

Thanks for the gem! I've been enjoying using it.

Looks like there isn't support for POST /api/submit. I think I see where to add it, but I wanted to check that I wasn't missing something before digging in.

Simplify the process of dealing with MoreComments objects.

The Problem

When iterating through comments in a submission, users have to deal with a MoreComments, an object that represents comments that need to be expanded manually. Expanding them is also a pain because the object returns a flat listing of comments, forcing me to manually reconstruct the hierarchy locally.

The Solution

A custom CommentListing type that expands MoreComments as you iterate through it and caches the resulting data.

Architecture

Initialization

  1. A CommentListing is initialized by the Submission to represent the comments.
  2. Every subsequent comment also initializes the CommentListing with a reference to the main Submission.

Expanding

  1. If it hasn't been done before, a method is called on the Submission to traverse the comment tree and store references to all subcomments by their id. All unexpanded MoreComments are also stored separately.
  2. The MoreComments object uses this to check where to push expanded comments to.
  3. This also helps users fetch all comments in a submission.

Redd::Models::Comment#new removed in 0.8.x and 0.9.x?

I'm writing a script that monitors various services (Twitter, Reddit, etc) for notifications.

Originally I used 0.7.10 and relied upon Redd::Models::Comment#new to determine if a comment was new or not. But it seems #new is not there in 0.8.x and 0.9.x. I didn't see an obvious replacement for it.

Is there another way I can find out if a particular comment is new (unread) or not?

Can I sticky a comment?

It looks like distinguish does not have this option.

Relevant

I naively tried comment.distinguish(:sticky) but got a 403 (I am a mod with full permissions).

Add ability to stream messages.

Requested in https://redd.it/76rrw4.

Is it possible to stream comment replies? e.g.:

session.my_messages(:category=>'comments').stream { |comment| .. }

Thanks in advance.

EDIT: It looks like PRAW supports it (see here). I wonder if it would be possible to duplicate this functionality in Redd.

Updating Stylesheets?

Hello!

I am working on an app that requires me to authenticate and update a subreddit's stylesheet. I am loving this wrapper and would love to use it, but I don't see this feature yet.

I just wanted to check in and see if it was in the pipeline, or if I missed it? I really appreciate all the work. It's great! 🍻

:permalink is inaccessible on a comment

It seems the permalink provided the Reddit API for comments is not accessible via the Comment model. I was wondering if there's a way to access it without having to construct it myself via getting the link.id of the submission?

Does this gem support the "save" scope?

I want to be able to retrieve a user's saved posts/comments (see app)

Does this gem offer such capability? I was thinking of using RedditKit, but as listed here, it does not support OAuth. However, I plan to use omniauth-reddit for signing in users to my app.

Thank you.

Implement Equality (==) on Models

Last thing I'll bug you with for a while!

I have a comment child, and that comment is the only reply to another comment parent.

reply = parent.reload.replies[0]
reply.body == child.body  # => true
reply.id == child.id  # => true
reply == child  # => false

I don't think that you can uniquely identify a comment with just its ID, but if you can get the post ID that they each replied to, then you could compare reply.id == child.id && reply.subreddit.id == child.subreddit.id && post_id == child.post_id (this already works for link posts with link_id but I'm not sure if an equivalent exists for self posts.

No way to use existing tokens in web app?

As far as I can tell, Redd.it wants a code from Redd.url when running as a web application. After saving the account's access token and refresh token to the database, I need to re-use those tokens at a later date to start accessing reddit again. It seems that Redd.it will only work for authorizing from scratch.

I also didn't see a way to set the duration parameter of a request in Redd.url, so I had to monkey patch that in.

TypeError: no implicit conversion of Symbol into Integer

So... a new exception occurred. Sorry to be breaking things...

I have no idea what caused this, redd probably received something unexpected back from the reddit API...

This happened after I introduced code for access refresh (see #19).

Stacktrace (most recent call first):

  redd/access.rb:24:in `[]'
    @access_token = body[:access_token]
  redd/access.rb:24:in `initialize'
    @access_token = body[:access_token]
  redd/clients/userless.rb:28:in `new'
    @access = Access.new(response.body)
  redd/clients/userless.rb:28:in `authorize!'
    @access = Access.new(response.body)
  /app/lib/reddit.rb:10:in `initialize'
    @reddit.authorize!
  /app/lib/reddit_provider.rb:13:in `new'
    @reddit       = Reddit.new(client_id, client_secret)
  /app/lib/reddit_provider.rb:13:in `initialize'
    @reddit       = Reddit.new(client_id, client_secret)
  reddit-provider.rb:7:in `new'
    RedditProvider.new.run
  reddit-provider.rb:7:in `block in <main>'
    RedditProvider.new.run
  raven/base.rb:96:in `capture'
    yield
  reddit-provider.rb:6:in `<main>'
    Raven.capture do

Non-moderator setting of flairs

I actually already have some code that implements /api/flairselector and /api/selectflair but I'm unsure of how you would like it attached to the existing codebase. Currently it's in subreddit.rb alongside the Subreddit#get_flair and Subreddit#set_flair methods. Perhaps inside a thing/Flairable.rb mixin would be better?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.