示例#1
0
def create_attachment(file_name: str, path_id: str, user_profile: UserProfile,
                      file_size: int) -> bool:
    attachment = Attachment.objects.create(file_name=file_name, path_id=path_id, owner=user_profile,
                                           realm=user_profile.realm, size=file_size)
    from zerver.lib.actions import notify_attachment_update
    notify_attachment_update(user_profile, 'add', attachment.to_dict())
    return True
示例#2
0
def create_attachment(file_name: str, path_id: str, user_profile: UserProfile,
                      file_size: int) -> bool:
    attachment = Attachment.objects.create(file_name=file_name, path_id=path_id, owner=user_profile,
                                           realm=user_profile.realm, size=file_size)
    from zerver.lib.actions import notify_attachment_update
    notify_attachment_update(user_profile, 'add', attachment.to_dict())
    return True
示例#3
0
def remove(request: HttpRequest, user_profile: UserProfile,
           attachment_id: int) -> HttpResponse:
    attachment = access_attachment_by_id(user_profile,
                                         attachment_id,
                                         needs_owner=True)
    notify_attachment_update(user_profile, "remove", {"id": attachment.id})
    remove_attachment(user_profile, attachment)
    return json_success()
示例#4
0
def create_attachment(file_name: str, path_id: str, user_profile: UserProfile,
                      realm: Realm, file_size: int) -> bool:
    assert (user_profile.realm_id == realm.id) or is_cross_realm_bot_email(
        user_profile.delivery_email)
    attachment = Attachment.objects.create(
        file_name=file_name,
        path_id=path_id,
        owner=user_profile,
        realm=realm,
        size=file_size,
    )
    from zerver.lib.actions import notify_attachment_update

    notify_attachment_update(user_profile, "add", attachment.to_dict())
    return True
示例#5
0
def remove(request: HttpRequest, user_profile: UserProfile, attachment_id: str) -> HttpResponse:
    attachment = access_attachment_by_id(user_profile, int(attachment_id),
                                         needs_owner=True)
    remove_attachment(user_profile, attachment)
    notify_attachment_update(user_profile, "remove", {"id": int(attachment_id)})
    return json_success()