|
66 | 66 | return null; |
67 | 67 | return AV.Object.createWithoutData('_Status', this.id); |
68 | 68 | }, |
| 69 | + _getDataJSON: function() { |
| 70 | + var json = AV._.clone(this.data); |
| 71 | + return AV._encode(json); |
| 72 | + }, |
69 | 73 | /** |
70 | 74 | * Send a status by a AV.Query object. |
71 | 75 | * <p>For example,send a status to male users:<br/><pre> |
|
101 | 105 | this.data = this.data || {}; |
102 | 106 | var currUser = AV.Object.createWithoutData('_User', AV.User.current().id)._toPointer(); |
103 | 107 | this.data.source = this.data.source || currUser; |
104 | | - data.data = this.data; |
| 108 | + data.data = this._getDataJSON(); |
105 | 109 | data.inboxType = this.inboxType || 'default'; |
106 | 110 |
|
107 | 111 | var request = AV._request('statuses', null, null, 'POST', data); |
|
113 | 117 | })._thenRunCallbacks(options); |
114 | 118 | }, |
115 | 119 |
|
116 | | - _finishFetch: function(data){ |
117 | | - this.id = data.objectId; |
118 | | - this.createdAt = AV._parseDate(data.createdAt); |
119 | | - this.updatedAt = AV._parseDate(data.updatedAt); |
120 | | - this.messageId = data.messageId; |
121 | | - delete data.messageId; |
122 | | - delete data.objectId; |
123 | | - delete data.createdAt; |
124 | | - delete data.updatedAt; |
125 | | - this.data = data; |
| 120 | + _finishFetch: function(serverData){ |
| 121 | + this.id = serverData.objectId; |
| 122 | + this.createdAt = AV._parseDate(serverData.createdAt); |
| 123 | + this.updatedAt = AV._parseDate(serverData.updatedAt); |
| 124 | + this.messageId = serverData.messageId; |
| 125 | + delete serverData.messageId; |
| 126 | + delete serverData.objectId; |
| 127 | + delete serverData.createdAt; |
| 128 | + delete serverData.updatedAt; |
| 129 | + this.data = AV._decode(undefined, serverData); |
126 | 130 | } |
127 | 131 | }; |
128 | 132 |
|
|
158 | 162 | data.query = query; |
159 | 163 | status.data = status.data || {}; |
160 | 164 | status.data.source = status.data.source || currUser; |
161 | | - data.data = status.data; |
| 165 | + data.data = status._getDataJSON(); |
162 | 166 | data.inboxType = status.inboxType || 'default'; |
163 | 167 |
|
164 | 168 | var request = AV._request('statuses', null, null, 'POST', data); |
|
210 | 214 | data.query = query; |
211 | 215 | status.data = status.data || {}; |
212 | 216 | status.data.source = status.data.source || currUser; |
213 | | - data.data = status.data; |
| 217 | + data.data = status._getDataJSON(); |
214 | 218 | data.inboxType = 'private'; |
215 | 219 | status.inboxType = 'private'; |
216 | 220 |
|
|
0 commit comments