Skip to content

Commit

Permalink
Fix the interpretation of JSON objects for direct messages.
Browse files Browse the repository at this point in the history
Thanks to Alexis who reported the problem.

* twittering-mode.el: Fix the interpretation of JSON objects for
direct messages. Thanks to Alexis who reported the problem.
(twittering-http-get-default-sentinel): use
`twittering-json-object-to-a-status-on-direct-messages' for
timelines related to direct messages.
(twittering-json-object-to-a-status-on-direct-messages): new
function.
  • Loading branch information
cvmat committed Dec 6, 2011
1 parent 2ae7ae0 commit e454907
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
(twittering-json-object-to-a-status-base): rearrange codes for
interpreting a JSON object.

* twittering-mode.el: Fix the interpretation of JSON objects for
direct messages. Thanks to Alexis who reported the problem.
(twittering-http-get-default-sentinel): use
`twittering-json-object-to-a-status-on-direct-messages' for
timelines related to direct messages.
(twittering-json-object-to-a-status-on-direct-messages): new
function.

2011-11-26 Tadashi MATSUO <tad@mymail.twin.jp>

* twittering-mode.el: Fix the strange behavior on moving the
Expand Down
50 changes: 50 additions & 0 deletions twittering-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,10 @@ the server when the HTTP status code equals to 400 or 403."
((eq (car spec) 'search)
(mapcar 'twittering-json-object-to-a-status-on-search
(cdr (assq 'results json-array))))
((twittering-timeline-spec-is-direct-messages-p spec)
(mapcar
'twittering-json-object-to-a-status-on-direct-messages
json-array))
(t
(mapcar 'twittering-json-object-to-a-status
json-array)))))
Expand Down Expand Up @@ -5406,6 +5410,52 @@ To convert a JSON object from other timelines, use
`((source . ,source)
(source-uri . ""))))))

(defun twittering-json-object-to-a-status-on-direct-messages (json-object)
"Convert JSON-OBJECT representing a tweet into an alist representation.
JSON-OBJECT must originate in timelines related to direct messages.
To convert a JSON object from other timelines, use
`twittering-json-object-to-a-status'."
`(,@(twittering-extract-common-element-from-json json-object)
,@(let ((symbol-table
'((id_str . id)
(recipient_screen_name . recipient-screen-name))))
(remove nil
(mapcar
(lambda (entry)
(let* ((sym (car entry))
(value (cdr entry))
(dest (cdr (assq sym symbol-table))))
(when (and dest value)
`(,dest . ,value))))
json-object)))
;; sender
,@(let ((symbol-table
'((id_str . user-id)
(name . user-name)
(profile_image_url . user-profile-image-url)
(protected . user-protected)
(screen_name . user-screen-name))))
(remove nil
(mapcar
(lambda (entry)
(let* ((sym (car entry))
(value (cdr entry))
(value
(cond
((eq sym 'protected)
(if (eq value :json-false)
nil
t))
((eq value :json-false)
nil)
(t
value))))
(when value
(let ((dest (cdr (assq sym symbol-table))))
(when dest
`(,dest . ,value))))))
(cdr (assq 'sender json-object)))))))

;;;;
;;;; List info retrieval
;;;;
Expand Down

0 comments on commit e454907

Please sign in to comment.