docs-mastodon/content/zh-cn/entities/Poll.md
2025-04-06 03:29:30 +08:00

3.2 KiB
Raw Blame History

title description menu aliases
Poll 表示被附加到嘟文的投票。
docs
parent
entities
/entities/poll
/entities/Poll
/api/entities/poll
/api/entities/Poll

示例

{
  "id": "34830",
  "expires_at": "2019-12-05T04:05:08.302Z",
  "expired": true,
  "multiple": false,
  "votes_count": 10,
  "voters_count": null,
  "voted": true,
  "own_votes": [
    1
  ],
  "options": [
    {
      "title": "accept",
      "votes_count": 6
    },
    {
      "title": "deny",
      "votes_count": 4
    }
  ],
  "emojis": []
}

属性

id

描述: 数据库中投票的ID。
类型: 字符串(从整数转换而来,但不保证是数字)
版本历史:
2.8.0 - 添加

expires_at

描述: 投票结束的时间。
类型: {{}} 字符串 (Datetime),如果投票永不结束,则为 null
版本历史:
2.8.0 - 添加

expired

描述: 投票当前是否已结束?
类型: 布尔值
版本历史:
2.8.0 - 添加

multiple

描述: 投票是否允许多选?
类型: 布尔值
版本历史:
2.8.0 - 添加

votes_count

描述: 投票收到的票数。
类型: 整数
版本历史:
2.8.0 - 添加

voters_count

描述: 在一个多选投票中,有多少个独立账户进行了投票。
类型: {{}} 整数,如果 multiple 为 false则为 null。
版本历史:
2.8.0 - 添加

options

描述: 投票的选项。
类型: Poll::Option 数组
版本历史:
2.8.0 - 添加

emojis

描述: 用于渲染投票选项的自定义表情。
类型: [CustomEmoji]({{< relref "entities/CustomEmoji" >}}) 数组
版本历史:
2.8.0 - 添加

voted {{%optional%}}

描述: 当使用用户令牌调用对应的 API 时,该令牌的授权用户是否已投票?
类型: 布尔值
版本历史:
2.8.0 - 添加

own_votes {{%optional%}}

描述: 当使用用户令牌调用对应的 API 时,该令牌的授权用户选择了哪些选项? 包含 options 的索引值数组。
类型: 整数数组
版本历史:
2.8.0 - 添加

Poll::Option 属性

title

描述: 投票选项的文本值。
类型: 字符串
版本历史:
2.8.0 - 添加

votes_count

描述: 此选项收到的总票数。
类型: {{}} 整数,如果结果尚未发布,则为 null。
版本历史:
2.8.0 - 添加

参见

{{< page-relref ref="entities/Status#poll" caption="嘟文 (poll 属性)" >}}

{{< page-relref ref="methods/polls" caption="polls API 方法" >}}

{{< caption-link url="https://github.com/mastodon/mastodon/blob/main/app/serializers/rest/poll_serializer.rb" caption="app/serializers/rest/poll_serializer.rb" >}}

{{< translation-status-zh-cn raw_title="Poll" raw_link="/entities/Poll/" last_translation_time="2025-04-06" raw_commit="5e2b739ee193896bea937addc2843146ea0bc870">}}