Merge branch 'test-speedup' into 'develop'
[akkoma] / test / web / ostatus / ostatus_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.OStatusTest do
6 use Pleroma.DataCase
7 alias Pleroma.Activity
8 alias Pleroma.Instances
9 alias Pleroma.Object
10 alias Pleroma.Repo
11 alias Pleroma.User
12 alias Pleroma.Web.OStatus
13 alias Pleroma.Web.XML
14
15 import ExUnit.CaptureLog
16 import Mock
17 import Pleroma.Factory
18
19 setup_all do
20 Tesla.Mock.mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
21 :ok
22 end
23
24 test "don't insert create notes twice" do
25 incoming = File.read!("test/fixtures/incoming_note_activity.xml")
26 {:ok, [activity]} = OStatus.handle_incoming(incoming)
27 assert {:ok, [activity]} == OStatus.handle_incoming(incoming)
28 end
29
30 test "handle incoming note - GS, Salmon" do
31 incoming = File.read!("test/fixtures/incoming_note_activity.xml")
32 {:ok, [activity]} = OStatus.handle_incoming(incoming)
33 object = Object.normalize(activity.data["object"])
34
35 user = User.get_cached_by_ap_id(activity.data["actor"])
36 assert user.info.note_count == 1
37 assert activity.data["type"] == "Create"
38 assert object.data["type"] == "Note"
39
40 assert object.data["id"] == "tag:gs.example.org:4040,2017-04-23:noticeId=29:objectType=note"
41
42 assert activity.data["published"] == "2017-04-23T14:51:03+00:00"
43 assert object.data["published"] == "2017-04-23T14:51:03+00:00"
44
45 assert activity.data["context"] ==
46 "tag:gs.example.org:4040,2017-04-23:objectType=thread:nonce=f09e22f58abd5c7b"
47
48 assert "http://pleroma.example.org:4000/users/lain3" in activity.data["to"]
49 assert object.data["emoji"] == %{"marko" => "marko.png", "reimu" => "reimu.png"}
50 assert activity.local == false
51 end
52
53 test "handle incoming notes - GS, subscription" do
54 incoming = File.read!("test/fixtures/ostatus_incoming_post.xml")
55 {:ok, [activity]} = OStatus.handle_incoming(incoming)
56 object = Object.normalize(activity.data["object"])
57
58 assert activity.data["type"] == "Create"
59 assert object.data["type"] == "Note"
60 assert object.data["actor"] == "https://social.heldscal.la/user/23211"
61 assert object.data["content"] == "Will it blend?"
62 user = User.get_cached_by_ap_id(activity.data["actor"])
63 assert User.ap_followers(user) in activity.data["to"]
64 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
65 end
66
67 test "handle incoming notes with attachments - GS, subscription" do
68 incoming = File.read!("test/fixtures/incoming_websub_gnusocial_attachments.xml")
69 {:ok, [activity]} = OStatus.handle_incoming(incoming)
70 object = Object.normalize(activity.data["object"])
71
72 assert activity.data["type"] == "Create"
73 assert object.data["type"] == "Note"
74 assert object.data["actor"] == "https://social.heldscal.la/user/23211"
75 assert object.data["attachment"] |> length == 2
76 assert object.data["external_url"] == "https://social.heldscal.la/notice/2020923"
77 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
78 end
79
80 test "handle incoming notes with tags" do
81 incoming = File.read!("test/fixtures/ostatus_incoming_post_tag.xml")
82 {:ok, [activity]} = OStatus.handle_incoming(incoming)
83 object = Object.normalize(activity.data["object"])
84
85 assert object.data["tag"] == ["nsfw"]
86 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
87 end
88
89 test "handle incoming notes - Mastodon, salmon, reply" do
90 # It uses the context of the replied to object
91 Repo.insert!(%Object{
92 data: %{
93 "id" => "https://pleroma.soykaf.com/objects/c237d966-ac75-4fe3-a87a-d89d71a3a7a4",
94 "context" => "2hu"
95 }
96 })
97
98 incoming = File.read!("test/fixtures/incoming_reply_mastodon.xml")
99 {:ok, [activity]} = OStatus.handle_incoming(incoming)
100 object = Object.normalize(activity.data["object"])
101
102 assert activity.data["type"] == "Create"
103 assert object.data["type"] == "Note"
104 assert object.data["actor"] == "https://mastodon.social/users/lambadalambda"
105 assert activity.data["context"] == "2hu"
106 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
107 end
108
109 test "handle incoming notes - Mastodon, with CW" do
110 incoming = File.read!("test/fixtures/mastodon-note-cw.xml")
111 {:ok, [activity]} = OStatus.handle_incoming(incoming)
112 object = Object.normalize(activity.data["object"])
113
114 assert activity.data["type"] == "Create"
115 assert object.data["type"] == "Note"
116 assert object.data["actor"] == "https://mastodon.social/users/lambadalambda"
117 assert object.data["summary"] == "technologic"
118 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
119 end
120
121 test "handle incoming unlisted messages, put public into cc" do
122 incoming = File.read!("test/fixtures/mastodon-note-unlisted.xml")
123 {:ok, [activity]} = OStatus.handle_incoming(incoming)
124 object = Object.normalize(activity.data["object"])
125
126 refute "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
127 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["cc"]
128 refute "https://www.w3.org/ns/activitystreams#Public" in object.data["to"]
129 assert "https://www.w3.org/ns/activitystreams#Public" in object.data["cc"]
130 end
131
132 test "handle incoming retweets - Mastodon, with CW" do
133 incoming = File.read!("test/fixtures/cw_retweet.xml")
134 {:ok, [[_activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
135 retweeted_object = Object.normalize(retweeted_activity.data["object"])
136
137 assert retweeted_object.data["summary"] == "Hey."
138 end
139
140 test "handle incoming notes - GS, subscription, reply" do
141 incoming = File.read!("test/fixtures/ostatus_incoming_reply.xml")
142 {:ok, [activity]} = OStatus.handle_incoming(incoming)
143 object = Object.normalize(activity.data["object"])
144
145 assert activity.data["type"] == "Create"
146 assert object.data["type"] == "Note"
147 assert object.data["actor"] == "https://social.heldscal.la/user/23211"
148
149 assert object.data["content"] ==
150 "@<a href=\"https://gs.archae.me/user/4687\" class=\"h-card u-url p-nickname mention\" title=\"shpbot\">shpbot</a> why not indeed."
151
152 assert object.data["inReplyTo"] ==
153 "tag:gs.archae.me,2017-04-30:noticeId=778260:objectType=note"
154
155 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
156 end
157
158 test "handle incoming retweets - GS, subscription" do
159 incoming = File.read!("test/fixtures/share-gs.xml")
160 {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
161
162 assert activity.data["type"] == "Announce"
163 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
164 assert activity.data["object"] == retweeted_activity.data["object"]
165 assert "https://pleroma.soykaf.com/users/lain" in activity.data["to"]
166 refute activity.local
167
168 retweeted_activity = Activity.get_by_id(retweeted_activity.id)
169 retweeted_object = Object.normalize(retweeted_activity.data["object"])
170 assert retweeted_activity.data["type"] == "Create"
171 assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
172 refute retweeted_activity.local
173 assert retweeted_object.data["announcement_count"] == 1
174 assert String.contains?(retweeted_object.data["content"], "mastodon")
175 refute String.contains?(retweeted_object.data["content"], "Test account")
176 end
177
178 test "handle incoming retweets - GS, subscription - local message" do
179 incoming = File.read!("test/fixtures/share-gs-local.xml")
180 note_activity = insert(:note_activity)
181 user = User.get_cached_by_ap_id(note_activity.data["actor"])
182
183 incoming =
184 incoming
185 |> String.replace("LOCAL_ID", note_activity.data["object"]["id"])
186 |> String.replace("LOCAL_USER", user.ap_id)
187
188 {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
189
190 assert activity.data["type"] == "Announce"
191 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
192 assert activity.data["object"] == retweeted_activity.data["object"]["id"]
193 assert user.ap_id in activity.data["to"]
194 refute activity.local
195
196 retweeted_activity = Activity.get_by_id(retweeted_activity.id)
197 assert note_activity.id == retweeted_activity.id
198 assert retweeted_activity.data["type"] == "Create"
199 assert retweeted_activity.data["actor"] == user.ap_id
200 assert retweeted_activity.local
201 assert retweeted_activity.data["object"]["announcement_count"] == 1
202 end
203
204 test "handle incoming retweets - Mastodon, salmon" do
205 incoming = File.read!("test/fixtures/share.xml")
206 {:ok, [[activity, retweeted_activity]]} = OStatus.handle_incoming(incoming)
207 retweeted_object = Object.normalize(retweeted_activity.data["object"])
208
209 assert activity.data["type"] == "Announce"
210 assert activity.data["actor"] == "https://mastodon.social/users/lambadalambda"
211 assert activity.data["object"] == retweeted_activity.data["object"]
212
213 assert activity.data["id"] ==
214 "tag:mastodon.social,2017-05-03:objectId=4934452:objectType=Status"
215
216 refute activity.local
217 assert retweeted_activity.data["type"] == "Create"
218 assert retweeted_activity.data["actor"] == "https://pleroma.soykaf.com/users/lain"
219 refute retweeted_activity.local
220 refute String.contains?(retweeted_object.data["content"], "Test account")
221 end
222
223 test "handle incoming favorites - GS, websub" do
224 capture_log(fn ->
225 incoming = File.read!("test/fixtures/favorite.xml")
226 {:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
227
228 assert activity.data["type"] == "Like"
229 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
230 assert activity.data["object"] == favorited_activity.data["object"]
231
232 assert activity.data["id"] ==
233 "tag:social.heldscal.la,2017-05-05:fave:23211:comment:2061643:2017-05-05T09:12:50+00:00"
234
235 refute activity.local
236 assert favorited_activity.data["type"] == "Create"
237 assert favorited_activity.data["actor"] == "https://shitposter.club/user/1"
238
239 assert favorited_activity.data["object"] ==
240 "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
241
242 refute favorited_activity.local
243 end)
244 end
245
246 test "handle conversation references" do
247 incoming = File.read!("test/fixtures/mastodon_conversation.xml")
248 {:ok, [activity]} = OStatus.handle_incoming(incoming)
249
250 assert activity.data["context"] ==
251 "tag:mastodon.social,2017-08-28:objectId=7876885:objectType=Conversation"
252 end
253
254 test "handle incoming favorites with locally available object - GS, websub" do
255 note_activity = insert(:note_activity)
256
257 incoming =
258 File.read!("test/fixtures/favorite_with_local_note.xml")
259 |> String.replace("localid", note_activity.data["object"]["id"])
260
261 {:ok, [[activity, favorited_activity]]} = OStatus.handle_incoming(incoming)
262
263 assert activity.data["type"] == "Like"
264 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
265 assert activity.data["object"] == favorited_activity.data["object"]["id"]
266 refute activity.local
267 assert note_activity.id == favorited_activity.id
268 assert favorited_activity.local
269 end
270
271 test_with_mock "handle incoming replies, fetching replied-to activities if we don't have them",
272 OStatus,
273 [:passthrough],
274 [] do
275 incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
276 {:ok, [activity]} = OStatus.handle_incoming(incoming)
277 object = Object.normalize(activity.data["object"], false)
278
279 assert activity.data["type"] == "Create"
280 assert object.data["type"] == "Note"
281
282 assert object.data["inReplyTo"] ==
283 "http://pleroma.example.org:4000/objects/55bce8fc-b423-46b1-af71-3759ab4670bc"
284
285 assert "http://pleroma.example.org:4000/users/lain5" in activity.data["to"]
286
287 assert object.data["id"] == "tag:gs.example.org:4040,2017-04-25:noticeId=55:objectType=note"
288
289 assert "https://www.w3.org/ns/activitystreams#Public" in activity.data["to"]
290
291 assert called(OStatus.fetch_activity_from_url(object.data["inReplyTo"], :_))
292 end
293
294 test_with_mock "handle incoming replies, not fetching replied-to activities beyond max_replies_depth",
295 OStatus,
296 [:passthrough],
297 [] do
298 incoming = File.read!("test/fixtures/incoming_note_activity_answer.xml")
299
300 with_mock Pleroma.Web.Federator,
301 allowed_incoming_reply_depth?: fn _ -> false end do
302 {:ok, [activity]} = OStatus.handle_incoming(incoming)
303 object = Object.normalize(activity.data["object"], false)
304
305 refute called(OStatus.fetch_activity_from_url(object.data["inReplyTo"], :_))
306 end
307 end
308
309 test "handle incoming follows" do
310 incoming = File.read!("test/fixtures/follow.xml")
311 {:ok, [activity]} = OStatus.handle_incoming(incoming)
312 assert activity.data["type"] == "Follow"
313
314 assert activity.data["id"] ==
315 "tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
316
317 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
318 assert activity.data["object"] == "https://pawoo.net/users/pekorino"
319 refute activity.local
320
321 follower = User.get_cached_by_ap_id(activity.data["actor"])
322 followed = User.get_cached_by_ap_id(activity.data["object"])
323
324 assert User.following?(follower, followed)
325 end
326
327 test "handle incoming unfollows with existing follow" do
328 incoming_follow = File.read!("test/fixtures/follow.xml")
329 {:ok, [_activity]} = OStatus.handle_incoming(incoming_follow)
330
331 incoming = File.read!("test/fixtures/unfollow.xml")
332 {:ok, [activity]} = OStatus.handle_incoming(incoming)
333
334 assert activity.data["type"] == "Undo"
335
336 assert activity.data["id"] ==
337 "undo:tag:social.heldscal.la,2017-05-07:subscription:23211:person:44803:2017-05-07T09:54:48+00:00"
338
339 assert activity.data["actor"] == "https://social.heldscal.la/user/23211"
340 assert is_map(activity.data["object"])
341 assert activity.data["object"]["type"] == "Follow"
342 assert activity.data["object"]["object"] == "https://pawoo.net/users/pekorino"
343 refute activity.local
344
345 follower = User.get_cached_by_ap_id(activity.data["actor"])
346 followed = User.get_cached_by_ap_id(activity.data["object"]["object"])
347
348 refute User.following?(follower, followed)
349 end
350
351 test "it clears `unreachable` federation status of the sender" do
352 incoming_reaction_xml = File.read!("test/fixtures/share-gs.xml")
353 doc = XML.parse_document(incoming_reaction_xml)
354 actor_uri = XML.string_from_xpath("//author/uri[1]", doc)
355 reacted_to_author_uri = XML.string_from_xpath("//author/uri[2]", doc)
356
357 Instances.set_consistently_unreachable(actor_uri)
358 Instances.set_consistently_unreachable(reacted_to_author_uri)
359 refute Instances.reachable?(actor_uri)
360 refute Instances.reachable?(reacted_to_author_uri)
361
362 {:ok, _} = OStatus.handle_incoming(incoming_reaction_xml)
363 assert Instances.reachable?(actor_uri)
364 refute Instances.reachable?(reacted_to_author_uri)
365 end
366
367 describe "new remote user creation" do
368 test "returns local users" do
369 local_user = insert(:user)
370 {:ok, user} = OStatus.find_or_make_user(local_user.ap_id)
371
372 assert user == local_user
373 end
374
375 test "tries to use the information in poco fields" do
376 uri = "https://social.heldscal.la/user/23211"
377
378 {:ok, user} = OStatus.find_or_make_user(uri)
379
380 user = User.get_cached_by_id(user.id)
381 assert user.name == "Constance Variable"
382 assert user.nickname == "lambadalambda@social.heldscal.la"
383 assert user.local == false
384 assert user.info.uri == uri
385 assert user.ap_id == uri
386 assert user.bio == "Call me Deacon Blues."
387 assert user.avatar["type"] == "Image"
388
389 {:ok, user_again} = OStatus.find_or_make_user(uri)
390
391 assert user == user_again
392 end
393
394 test "find_or_make_user sets all the nessary input fields" do
395 uri = "https://social.heldscal.la/user/23211"
396 {:ok, user} = OStatus.find_or_make_user(uri)
397
398 assert user.info ==
399 %User.Info{
400 id: user.info.id,
401 ap_enabled: false,
402 background: %{},
403 banner: %{},
404 blocks: [],
405 deactivated: false,
406 default_scope: "public",
407 domain_blocks: [],
408 follower_count: 0,
409 is_admin: false,
410 is_moderator: false,
411 keys: nil,
412 locked: false,
413 no_rich_text: false,
414 note_count: 0,
415 settings: nil,
416 source_data: %{},
417 hub: "https://social.heldscal.la/main/push/hub",
418 magic_key:
419 "RSA.uzg6r1peZU0vXGADWxGJ0PE34WvmhjUmydbX5YYdOiXfODVLwCMi1umGoqUDm-mRu4vNEdFBVJU1CpFA7dKzWgIsqsa501i2XqElmEveXRLvNRWFB6nG03Q5OUY2as8eE54BJm0p20GkMfIJGwP6TSFb-ICp3QjzbatuSPJ6xCE=.AQAB",
420 salmon: "https://social.heldscal.la/main/salmon/user/23211",
421 topic: "https://social.heldscal.la/api/statuses/user_timeline/23211.atom",
422 uri: "https://social.heldscal.la/user/23211"
423 }
424 end
425
426 test "find_make_or_update_user takes an author element and returns an updated user" do
427 uri = "https://social.heldscal.la/user/23211"
428
429 {:ok, user} = OStatus.find_or_make_user(uri)
430 old_name = user.name
431 old_bio = user.bio
432 change = Ecto.Changeset.change(user, %{avatar: nil, bio: nil, name: nil})
433
434 {:ok, user} = Repo.update(change)
435 refute user.avatar
436
437 doc = XML.parse_document(File.read!("test/fixtures/23211.atom"))
438 [author] = :xmerl_xpath.string('//author[1]', doc)
439 {:ok, user} = OStatus.find_make_or_update_user(author)
440 assert user.avatar["type"] == "Image"
441 assert user.name == old_name
442 assert user.bio == old_bio
443
444 {:ok, user_again} = OStatus.find_make_or_update_user(author)
445 assert user_again == user
446 end
447 end
448
449 describe "gathering user info from a user id" do
450 test "it returns user info in a hash" do
451 user = "shp@social.heldscal.la"
452
453 # TODO: make test local
454 {:ok, data} = OStatus.gather_user_info(user)
455
456 expected = %{
457 "hub" => "https://social.heldscal.la/main/push/hub",
458 "magic_key" =>
459 "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
460 "name" => "shp",
461 "nickname" => "shp",
462 "salmon" => "https://social.heldscal.la/main/salmon/user/29191",
463 "subject" => "acct:shp@social.heldscal.la",
464 "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
465 "uri" => "https://social.heldscal.la/user/29191",
466 "host" => "social.heldscal.la",
467 "fqn" => user,
468 "bio" => "cofe",
469 "avatar" => %{
470 "type" => "Image",
471 "url" => [
472 %{
473 "href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg",
474 "mediaType" => "image/jpeg",
475 "type" => "Link"
476 }
477 ]
478 },
479 "subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}",
480 "ap_id" => nil
481 }
482
483 assert data == expected
484 end
485
486 test "it works with the uri" do
487 user = "https://social.heldscal.la/user/29191"
488
489 # TODO: make test local
490 {:ok, data} = OStatus.gather_user_info(user)
491
492 expected = %{
493 "hub" => "https://social.heldscal.la/main/push/hub",
494 "magic_key" =>
495 "RSA.wQ3i9UA0qmAxZ0WTIp4a-waZn_17Ez1pEEmqmqoooRsG1_BvpmOvLN0G2tEcWWxl2KOtdQMCiPptmQObeZeuj48mdsDZ4ArQinexY2hCCTcbV8Xpswpkb8K05RcKipdg07pnI7tAgQ0VWSZDImncL6YUGlG5YN8b5TjGOwk2VG8=.AQAB",
496 "name" => "shp",
497 "nickname" => "shp",
498 "salmon" => "https://social.heldscal.la/main/salmon/user/29191",
499 "subject" => "https://social.heldscal.la/user/29191",
500 "topic" => "https://social.heldscal.la/api/statuses/user_timeline/29191.atom",
501 "uri" => "https://social.heldscal.la/user/29191",
502 "host" => "social.heldscal.la",
503 "fqn" => user,
504 "bio" => "cofe",
505 "avatar" => %{
506 "type" => "Image",
507 "url" => [
508 %{
509 "href" => "https://social.heldscal.la/avatar/29191-original-20170421154949.jpeg",
510 "mediaType" => "image/jpeg",
511 "type" => "Link"
512 }
513 ]
514 },
515 "subscribe_address" => "https://social.heldscal.la/main/ostatussub?profile={uri}",
516 "ap_id" => nil
517 }
518
519 assert data == expected
520 end
521 end
522
523 describe "fetching a status by it's HTML url" do
524 test "it builds a missing status from an html url" do
525 capture_log(fn ->
526 url = "https://shitposter.club/notice/2827873"
527 {:ok, [activity]} = OStatus.fetch_activity_from_url(url)
528
529 assert activity.data["actor"] == "https://shitposter.club/user/1"
530
531 assert activity.data["object"] ==
532 "tag:shitposter.club,2017-05-05:noticeId=2827873:objectType=comment"
533 end)
534 end
535
536 test "it works for atom notes, too" do
537 url = "https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056"
538 {:ok, [activity]} = OStatus.fetch_activity_from_url(url)
539 assert activity.data["actor"] == "https://social.sakamoto.gq/users/eal"
540 assert activity.data["object"] == url
541 end
542 end
543
544 test "it doesn't add nil in the to field" do
545 incoming = File.read!("test/fixtures/nil_mention_entry.xml")
546 {:ok, [activity]} = OStatus.handle_incoming(incoming)
547
548 assert activity.data["to"] == [
549 "http://localhost:4001/users/atarifrosch@social.stopwatchingus-heidelberg.de/followers",
550 "https://www.w3.org/ns/activitystreams#Public"
551 ]
552 end
553
554 describe "is_representable?" do
555 test "Note objects are representable" do
556 note_activity = insert(:note_activity)
557
558 assert OStatus.is_representable?(note_activity)
559 end
560
561 test "Article objects are not representable" do
562 note_activity = insert(:note_activity)
563
564 note_object = Object.normalize(note_activity.data["object"])
565
566 note_data =
567 note_object.data
568 |> Map.put("type", "Article")
569
570 Cachex.clear(:object_cache)
571
572 cs = Object.change(note_object, %{data: note_data})
573 {:ok, _article_object} = Repo.update(cs)
574
575 # the underlying object is now an Article instead of a note, so this should fail
576 refute OStatus.is_representable?(note_activity)
577 end
578 end
579 end